<?php


class VodCategory extends CActiveRecord
{
        public $Vxryw0uo3pmq;
        public $Veggaarzpo5h;
        public $Vx42oml1vxwz='';
	
	public static function model($Vgmajjibziuy=__CLASS__)
	{
		return parent::model($Vgmajjibziuy);
	}

	
	public function tableName()
	{
		return 'vod_category';
	}

	
	public function rules()
	{
		
		
		return array(
			array('code_name, display_name, create_date', 'required'),
			array('status, order_number, parent_id, level, child_count, create_user_id, modify_user_id', 'numerical', 'integerOnly'=>true),
			array('code_name, display_name, display_name_ascii, path', 'length', 'max'=>200),
			array('image_url, tags, tags_ascii', 'length', 'max'=>500),
			array('description, description_ascii, status_log, modify_date', 'safe'),
			
			
			array('id, code_name, display_name, display_name_ascii, description, description_ascii, status, status_log, order_number, parent_id, path, level, child_count, image_url, tags, tags_ascii, create_date, modify_date, create_user_id, modify_user_id', 'safe', 'on'=>'search'),
		);
	}

	
	public function relations()
	{
		
		
		return array(
			'createUser' => array(self::BELONGS_TO, 'BackendUser', 'create_user_id'),
			'modifyUser' => array(self::BELONGS_TO, 'BackendUser', 'modify_user_id'),
			'parent' => array(self::BELONGS_TO, 'VodCategory', 'parent_id'),
			'vodCategories' => array(self::HAS_MANY, 'VodCategory', 'parent_id'),
			'vodCategoryAssetMappings' => array(self::HAS_MANY, 'VodCategoryAssetMapping', 'vod_category_id'),
			'vodCategorySerieMappings' => array(self::HAS_MANY, 'VodCategorySerieMapping', 'vod_category_id'),
			'vodSearchHistories' => array(self::HAS_MANY, 'VodSearchHistory', 'vod_category_id'),
		);
	}

	
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'code_name' => 'Code Name',
			'display_name' => 'Display Name',
			'display_name_ascii' => 'Display Name Ascii',
			'description' => 'Description',
			'description_ascii' => 'Description Ascii',
			'status' => 'Status',
			'status_log' => 'Status Log',
			'order_number' => 'Order Number',
			'parent_id' => 'Parent',
			'path' => 'Path',
			'level' => 'Level',
			'child_count' => 'Child Count',
			'image_url' => 'Image Url',
			'tags' => 'Tags',
			'tags_ascii' => 'Tags Ascii',
			'create_date' => 'Create Date',
			'modify_date' => 'Modify Date',
			'create_user_id' => 'Create User',
			'modify_user_id' => 'Modify User',
		);
	}

	
	public function search()
	{
		
		

		$V0v5vsnfxezw=new CDbCriteria;

		$V0v5vsnfxezw->compare('id',$this->id);
		$V0v5vsnfxezw->compare('code_name',$this->code_name,true);
		$V0v5vsnfxezw->compare('display_name',$this->display_name,true);
		$V0v5vsnfxezw->compare('display_name_ascii',$this->display_name_ascii,true);
		$V0v5vsnfxezw->compare('description',$this->description,true);
		$V0v5vsnfxezw->compare('description_ascii',$this->description_ascii,true);
		$V0v5vsnfxezw->compare('status',$this->status);
		$V0v5vsnfxezw->compare('status_log',$this->status_log,true);
		$V0v5vsnfxezw->compare('order_number',$this->order_number);
		$V0v5vsnfxezw->compare('parent_id',$this->parent_id);
		$V0v5vsnfxezw->compare('path',$this->path,true);
		$V0v5vsnfxezw->compare('level',$this->level);
		$V0v5vsnfxezw->compare('child_count',$this->child_count);
		$V0v5vsnfxezw->compare('image_url',$this->image_url,true);
		$V0v5vsnfxezw->compare('tags',$this->tags,true);
		$V0v5vsnfxezw->compare('tags_ascii',$this->tags_ascii,true);
		$V0v5vsnfxezw->compare('create_date',$this->create_date,true);
		$V0v5vsnfxezw->compare('modify_date',$this->modify_date,true);
		$V0v5vsnfxezw->compare('create_user_id',$this->create_user_id);
		$V0v5vsnfxezw->compare('modify_user_id',$this->modify_user_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$V0v5vsnfxezw,
		));
	}

       public function getListedForJUI() {
                
                $V0o2xhmgxaar = array('0'.$this->id=>$this->path_name);
                if($this->vodCategories) foreach($this->vodCategories as $Vfbakkyxqwgf) 
                    if ($Vfbakkyxqwgf->status!=2){    
                       for ($Virckwbeg044 = 0; $Virckwbeg044 < $Vfbakkyxqwgf->level; $Virckwbeg044++) 
                            $Vfbakkyxqwgf->path_name .= "----| ";
                       $Vfbakkyxqwgf->path_name .= $Vfbakkyxqwgf->display_name;
                       $V0o2xhmgxaar = array_merge($V0o2xhmgxaar, $Vfbakkyxqwgf->getListedForJUI());
                       
                    }
                return $V0o2xhmgxaar;
       }
       
       public function getListed($Virckwbeg044d=null) {
               $V0o2xhmgxaar=array();
               if ($Virckwbeg044d!=$this->id) {
                    $V0o2xhmgxaar = array($this); 
                    if($this->vodCategories) {
                        foreach($this->vodCategories as $Vfbakkyxqwgf) {
                            if ($Vfbakkyxqwgf->status!=2){                       
                               for ($Virckwbeg044=0;$Virckwbeg044<$Vfbakkyxqwgf->level;$Virckwbeg044++) 
                                    $Vfbakkyxqwgf->path_name .= "----| ";
                               $Vfbakkyxqwgf->path_name .= $Vfbakkyxqwgf->display_name;
                               $V0o2xhmgxaar = array_merge($V0o2xhmgxaar,$Vfbakkyxqwgf->getListed($Virckwbeg044d));

                            }
                        }
                    }
                }
                return $V0o2xhmgxaar;
       } 
       
       public function getListSub($Virckwbeg044d=null) { 
               $V0o2xhmgxaar=array();
               if ($Virckwbeg044d!=$this->id) {
                    $V0o2xhmgxaar = array(); 
                    if($this->vodCategories) {
                        foreach($this->vodCategories as $Vfbakkyxqwgf) {
                            if ($Vfbakkyxqwgf->status!=2){                       
                               for ($Virckwbeg044=0;$Virckwbeg044<$Vfbakkyxqwgf->level;$Virckwbeg044++) 
                                    $Vfbakkyxqwgf->path_name .= "----| ";
                               $Vfbakkyxqwgf->path_name .= $Vfbakkyxqwgf->display_name;
                               $V0o2xhmgxaar = array_merge($V0o2xhmgxaar,$Vfbakkyxqwgf->getListed($Virckwbeg044d));

                            }
                        }
                    }
                }
                return $V0o2xhmgxaar;
       } 
       
       public function getCategoryCount() {
           if ($this->parent_id == NULL) {
               $Vrk3odha4mic = count(VodCategory::model()->findAllByAttributes(array('level'=>0)));
           } else $Vrk3odha4mic = count($this->parent->vodCategories);
           
           return $Vrk3odha4mic;
       }
       
       public function getPathName() {
           $Virckwbeg044tem = $this;
           $Vfcisoqdzruw = $Virckwbeg044tem->display_name;
           while ($Virckwbeg044tem->level!=0) {
               $Virckwbeg044tem = $Virckwbeg044tem->parent;
               $Vfcisoqdzruw = $Virckwbeg044tem->display_name.'/'.$Vfcisoqdzruw;
           }
           return $Vfcisoqdzruw;
       }
}